{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "<a href=\"https://githubtocolab.com/gee-community/geemap/blob/master/docs/notebooks/115_land_cover.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>\n",
    "\n",
    "**Comparing Dynamic World with ESA and ESRI global land cover data**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install geemap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ee\n",
    "import geemap"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3",
   "metadata": {},
   "source": [
    "Visualizing [ESA Global Land Cover](https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v100)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "esa = ee.ImageCollection(\"ESA/WorldCover/v100\").first()\n",
    "esa_vis = {\"bands\": [\"Map\"]}\n",
    "\n",
    "Map.addLayer(esa, esa_vis, \"ESA Land Cover\")\n",
    "Map.add_legend(title=\"ESA Land Cover\", builtin_legend=\"ESA_WorldCover\")\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5",
   "metadata": {},
   "source": [
    "Visualizing [ESRI Global Land Cover](https://samapriya.github.io/awesome-gee-community-datasets/projects/esrilc2020)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "esri = ee.ImageCollection(\n",
    "    \"projects/sat-io/open-datasets/landcover/ESRI_Global-LULC_10m\"\n",
    ").mosaic()\n",
    "esri_vis = {\n",
    "    \"min\": 1,\n",
    "    \"max\": 10,\n",
    "    \"palette\": [\n",
    "        \"#1A5BAB\",\n",
    "        \"#358221\",\n",
    "        \"#A7D282\",\n",
    "        \"#87D19E\",\n",
    "        \"#FFDB5C\",\n",
    "        \"#EECFA8\",\n",
    "        \"#ED022A\",\n",
    "        \"#EDE9E4\",\n",
    "        \"#F2FAFF\",\n",
    "        \"#C8C8C8\",\n",
    "    ],\n",
    "}\n",
    "\n",
    "Map.addLayer(esri, esri_vis, \"ESRI Land Cover\")\n",
    "Map.add_legend(title=\"ESRI Land Cover\", builtin_legend=\"ESRI_LandCover\")\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7",
   "metadata": {},
   "source": [
    "Visualizing [Dynamic World Land Cover](https://developers.google.com/earth-engine/datasets/catalog/GOOGLE_DYNAMICWORLD_V1?hl=en)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map()\n",
    "\n",
    "region = ee.Geometry.BBox(-179, -89, 179, 89)\n",
    "start_date = \"2021-01-01\"\n",
    "end_date = \"2022-01-01\"\n",
    "\n",
    "dw_class = geemap.dynamic_world(region, start_date, end_date, return_type=\"class\")\n",
    "dw = geemap.dynamic_world(region, start_date, end_date, return_type=\"hillshade\")\n",
    "\n",
    "dw_vis = {\n",
    "    \"min\": 0,\n",
    "    \"max\": 8,\n",
    "    \"palette\": [\n",
    "        \"#419BDF\",\n",
    "        \"#397D49\",\n",
    "        \"#88B053\",\n",
    "        \"#7A87C6\",\n",
    "        \"#E49635\",\n",
    "        \"#DFC35A\",\n",
    "        \"#C4281B\",\n",
    "        \"#A59B8F\",\n",
    "        \"#B39FE1\",\n",
    "    ],\n",
    "}\n",
    "\n",
    "Map.addLayer(dw_class, dw_vis, \"DW Land Cover\", False)\n",
    "Map.addLayer(dw, {}, \"DW Land Cover Hillshade\")\n",
    "\n",
    "Map.add_legend(title=\"Dynamic World Land Cover\", builtin_legend=\"Dynamic_World\")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9",
   "metadata": {},
   "source": [
    "Comparing Dynamic World with ESA Land Cover."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map(center=[39.3322, -106.7349], zoom=10)\n",
    "\n",
    "left_layer = geemap.ee_tile_layer(esa, esa_vis, \"ESA Land Cover\")\n",
    "right_layer = geemap.ee_tile_layer(dw, {}, \"Dynamic World Land Cover\")\n",
    "\n",
    "Map.split_map(left_layer, right_layer)\n",
    "Map.add_legend(\n",
    "    title=\"ESA Land Cover\", builtin_legend=\"ESA_WorldCover\", position=\"bottomleft\"\n",
    ")\n",
    "Map.add_legend(\n",
    "    title=\"Dynamic World Land Cover\",\n",
    "    builtin_legend=\"Dynamic_World\",\n",
    "    position=\"bottomright\",\n",
    ")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "\n",
    "Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11",
   "metadata": {},
   "source": [
    "Comparing Dynamic World with ESRI Land Cover."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12",
   "metadata": {},
   "outputs": [],
   "source": [
    "Map = geemap.Map(center=[-89.3998, 43.0886], zoom=10)\n",
    "\n",
    "left_layer = geemap.ee_tile_layer(esri, esri_vis, \"ESRI Land Cover\")\n",
    "right_layer = geemap.ee_tile_layer(dw, {}, \"Dynamic World Land Cover\")\n",
    "\n",
    "Map.split_map(left_layer, right_layer)\n",
    "Map.add_legend(\n",
    "    title=\"ESRI Land Cover\", builtin_legend=\"ESRI_LandCover\", position=\"bottomleft\"\n",
    ")\n",
    "Map.add_legend(\n",
    "    title=\"Dynamic World Land Cover\",\n",
    "    builtin_legend=\"Dynamic_World\",\n",
    "    position=\"bottomright\",\n",
    ")\n",
    "Map.setCenter(-88.9088, 43.0006, 12)\n",
    "\n",
    "Map"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
